import api from '../../http/api'
export default {
    namespaced: true,
    state: {
        isfalse: false,
        isshow: false,
        dialogVisible: false,
        drawer: false,
        isSolutionToHang:false,
        pageSize: 8,
        pages: 0,
        currentPage: 1,
        total: 0,
        memberList: [],
        listmeber:[]
    },
    mutations: {
        setState(state,newdata) {
        //    console.log('newdata',newdata);
            state.pages=newdata.pages;
            state.total=newdata.total;
            state.memberList=newdata.data;
        },
        setStateA(state,newdata) {
            // state.pages=newdata.pages;
            // state.total=newdata.total;
            state.listmeber=newdata.data;
            // console.log(' state.listmeber', state.listmeber);
        },
        setpageSize(state,newdata){
            state.pagesize=newdata
        },
        setCurrentPage(state,newdata){
            state.currentPage=newdata
        }
    },
    actions: {
        async memberAdd(context, data) {
            return await api.member.memberAdd(data)
        },
        async memberSech(context,id) {  
        //    console.log("c",id);
            const data= await api.member.memberSech({
                data:{id},
                currentPage: 1,
                pageSize: context.state.pageSize
            })
            // console.log("c",data);
 
            if (data.data.code == 200) {
                context.commit('setStateA', data.data.data)
            }
        },
        //页面渲染
        async searchReceptionistMember(context,newdata){
            const data = await api.member.searchReceptionistMember({
                data:{memberName:newdata.name,memberPhoneNumber:newdata.phone},
                currentPage: context.state.currentPage,
                pageSize: context.state.pageSize
            })
            if (data.data.code == 200) {
                context.commit('setState', data.data.data)
            }
        },
        async member(context,newdata){
            return await api.member.member(newdata)
        }
    },
    modules: {}
}